import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import pojo.User;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @Classname MybatisDemoo
 * @Description TODO
 * @Date 2022/3/20 2:55
 * @Created by Hui
 */
public class MybatisDemo {
    public static void main(String[] args) throws Exception {
        //加载核心文件
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);

        //获取SqlSession对象，执行sql
        SqlSession sqlSession = sqlSessionFactory.openSession();


        //执行sql
          //List<User> users = sqlSession.selectList("test.selectALL");
          List<User> users = sqlSession.selectList("test.selectAll");

        System.out.println(users);


        sqlSession.close();


    }


}
